#include "util/TimeManager.h"
#include "SDL/SDL.h"

namespace util {

TimeManager::TimeManager() {
	SDL_InitSubSystem(SDL_INIT_TIMER);
	this->startTime = 0;
	this->stopTime = 0;
	this->started = false;
}

TimeManager::~TimeManager() {
	SDL_QuitSubSystem(SDL_INIT_TIMER);
}

void TimeManager::startCounting() {
	this->started = true;
	this->startTime = SDL_GetTicks();
}

void TimeManager::stopCounting() {
	if (this->started) {
		this->stopTime = SDL_GetTicks();
		this->started = false;
	}
}

Uint32 TimeManager::elapsedTime() {
	return this->stopTime - this->startTime;
}

void TimeManager::delay(Uint32 timeToDelay) {
	SDL_Delay(timeToDelay);
}

}
